package nl.hu.verbrandendephoenix.shared;

import java.util.ArrayList;

import com.google.gwt.user.client.rpc.IsSerializable;

public class Conversation implements IsSerializable {
	private ArrayList<Message> messages;
	private User contact;
	private String last_message;
	private int CID_;
	
	public Conversation() {}
	
	//For conversation listing
	public Conversation(User u, String lstmsg) {
		contact = u;
		messages = new ArrayList<Message>();
		last_message = lstmsg;
	}
	
	public Conversation(User u, String lstmsg, int key) {
		contact = u;
		messages = new ArrayList<Message>();
		last_message = lstmsg;
		CID_ = key;
	}

	//For in conversation itself
	public Conversation(int key, User u, ArrayList<Message> m) {
		contact = u;
		messages = m;
		CID_ = key;
	}
	
	public ArrayList<Message> getMessages() {
		return messages;
	}
	
	public User getContact() {
		return contact;
	}
	
	public void addMessage(Message m) {
		messages.add(m);
	}
	
	public void deleteMessage(int i) {
		messages.remove(i);
	}
	
	public Message getMessage(int i) {
		return messages.get(i);
	}
	
	public String getLast() {
		return last_message;
	}
	
	public void setLast(String l) {
		last_message = l;
	}
	
	public void setID(int key) {
		CID_ = key;
	}
	
	public void setPartner(User u) {
		contact = u;
	}
	
	public void setMessages(ArrayList<Message> m) {
		messages = m;
	}

	public int getCID() {
		return CID_;
	}
}
